<?php
class OrderStateAction extends CommonAction {
	
	
	/**
	 * 查询(non-PHPdoc)
	 * @see CommonAction::read()
	 * **/
	 public function read() {
	 if(!empty($_POST['GZ_DDH'])) {
	 $map['GZ_DDH'] = array('like',"%".$_POST['GZ_DDH']."%");
	 }
	 if(!empty($_POST['GZ_CZRM'])) {
	 $map['GZ_CZRM'] = array('like',"%".$_POST['GZ_CZRM']."%");
	 }

	 if((!empty($_POST['GZ_CZSJ_BEGIN']))&&(!empty($_POST['GZ_CZSJ_END']))) {
	  $map['GZ_CZSJ'] = $map['id']  = array('between',array($_POST['GZ_CZSJ_BEGIN'],$_POST['GZ_CZSJ_END']));
	 }
	 
	 $pagenum = isset ( $_POST ['page'] ) ? intval ( $_POST ['page'] ) : 1;
	 $rowsnum = isset ( $_POST ['rows'] ) ? intval ( $_POST ['rows'] ) : 10;
	 
	 $OrderState = D ("OrderState");
	 $fix = C( "DB_PREFIX" );
	
	 $total = $OrderState->where($map)->count (); // 计算总数
	 import("ORG.Util.Page");// 导入分页类
	 
	 $gztList = array ();
	 $gztList = $OrderState->where($map)->limit ( ($pagenum - 1) * $rowsnum . ',' . $rowsnum )->order ( 'GZ_CZSJ desc' )->select ();
	 
	 $resultJson = json_encode($gztList);
	 
	 if($resultJson == "null"){//如果查询结果返回为null
	 $resultJson = "[]";
	 }
	 $json = '{"total":' . $total . ',"rows":' . $resultJson . '}'; // 重要，easyui的标准数据格式，数据总数和数据内容在同一个json中
	 echo $json;
	 }
	
	 
	 /**
	  * 保存订单跟踪信息
	  */
	 public function  saveDDGZ($dd_bh,$dd_ddbh,$czr_id,$czr_name){
	 	$result = false;
	 	$OrderState = D ( "OrderState" );
	 	$gj = $OrderState->getDD_GJ($dd_ddbh);

	 	$data ['GZ_DDH'] = $dd_bh;
	 	$data ['GZ_GJ'] = $gj;
	 	$dd_cjsj = date("Y-m-d H:i:s", time());//获取系统当前时间
	 	
	 	$data ['GZ_CZSJ'] = $dd_cjsj;
	 	$data ['GZ_CZRID'] = $czr_id;
	 	$data ['GZ_CZRM'] = $czr_name;

	 	$result = $OrderState->add($data);
	 	return $result;

	 }
}
?>